package com.hero.controller;

import com.hero.entity.Section;
import com.hero.entity.Section;
import com.hero.service.SectionService;
import com.hero.utils.ResponseJson;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 科室信息(Section)表控制层
 *
 * @author makejava
 * @since 2021-06-30 18:55:44
 */
@RestController
@RequestMapping("/sec")
public class SectionController {
    /**
     * 服务对象
     */
    @Autowired
    private SectionService sectionService;
    
    @PostMapping("/insert")
    public ResponseJson add(@RequestBody Section entity){
        sectionService.insert(entity);
        return ResponseJson.success();
    }

    @PutMapping("/update")
    public ResponseJson edit(@RequestBody Section entity){
        sectionService.update(entity);
        return ResponseJson.success();
    }

    @DeleteMapping("/delete/{id}")
    public ResponseJson remove(@PathVariable Integer id){
        sectionService.deleteById(id);
        return ResponseJson.success();
    }

//    @DeleteMapping("/remove")
//    public ResponseJson removeBatch(Integer[] id){
//        sectionService.removeBatch(id);
//        return ResponseJson.success();
//    }

    @GetMapping("/find/{id}")
    public ResponseJson findById(@PathVariable Integer id){
        return ResponseJson.success(sectionService.queryById(id));
    }

    @GetMapping("/find")
    public ResponseJson find(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
                             @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
                             Section entity){
        return ResponseJson.success(sectionService.find(pageNum, pageSize, entity));
    }

    @GetMapping("/findAll")
    public ResponseJson findAll(){
        return ResponseJson.success(sectionService.queryAll());
    }

}
